package edu.sctu.wangxiaoqiang.day20150625.io_package;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.io.*;

/**
 * Created by user25 on 2015/6/25.
 */
public class IOUtil {
    /*字节流
     *读取指定文件内容，按照16进制输出到控制台
     * 每输出10个byte换行
     */
    public void printHex(String fileName){
        try {
            FileInputStream fi = new FileInputStream(fileName);
//            FileOutputStream fo = new FileOutputStream(fileName);
            int b;
            int i=1;
            try {
                while ((b = fi.read()) != -1){
                    System.out.print(b);
//                    System.out.print(Integer.toHexString(b) + "  ");
                    if(i++%10==0){
                        System.out.println();
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fi.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
